#ifndef _FUZZY_24BIN_H_
#define _FUZZY_24BIN_H_

#pragma once

#include <vector>
#include <iterator>

#ifndef MIN
#define MIN(a,b)  ((a) > (b) ? (b) : (a))
#endif

#ifndef MAX
#define MAX(a,b)  ((a) < (b) ? (b) : (a))
#endif

using namespace std;

class Fuzzy24Bin
{
public:
	Fuzzy24Bin(void);
	~Fuzzy24Bin(void);

	Fuzzy24Bin(bool KeepPreviuesValues);

	vector<double> ApplyFilter(double Hue, double Saturation, double Value, vector<double>& ColorValues, int Method);
	
public:
	struct FuzzyRules
	{
		int Input1;
		int Input2;
		int Output;
	};

	bool					_KeepPreviusValues;
	vector<double>			_ResultsTable;
	vector<double>			_Fuzzy24BinHisto;
	vector<double>			_SaturationMembershipValues;
	vector<double>			_ValueMembershipValues;
	vector<double>			_SaturationActivation;
	vector<double>			_ValueActivation;
	vector<vector<int> >	_Fuzzy24BinRulesDefinition;
	vector<FuzzyRules>		_Fuzzy24BinRules;

private:

	void ParamsInit();
	
	void FindMembershipValueForTriangles(double Input, vector<double>& Triangles, vector<double>& MembershipFunctionToSave);
	
	void LOM_Defazzificator(vector<FuzzyRules>& Rules, vector<double>& Input1, vector<double>& Input2,  vector<double>& ResultTable);
	
	void MultiParticipate_Equal_Defazzificator(vector<FuzzyRules>& Rules, vector<double>& Input1, vector<double>& Input2,  vector<double>& ResultTable);
	
	void MultiParticipate_Defazzificator(vector<FuzzyRules>& Rules, vector<double>& Input1, vector<double>& Input2,  vector<double>& ResultTable);

};

#endif